package gui;

import java.awt.Color;
import java.awt.Rectangle;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JTextField;

import client.Client;

public class MainSystemManger extends JFrame{
	private JPanel mainform = null;
	private MainPanel MP;
	private JLabel jLabelWelcome = null;
	private JButton jButtonCatalog = null;
	private JButton jButtonOrder = null;
	private JButton jButtonExit = null;
	private JButton jButtonHelp = null;
	private JLabel jLabelLogIn = null;
	JTextField jTextFieldloginInfo = null;
	private JLabel jLabelBackground = null;
	final public static int DEFAULT_PORT = 5555;  
    private String host = MainPanel.ip; //  @jve:decl-index=0:
	
    /*
	 * 
	 *
	private String[] Orderinfo;
	private String[] GetInfo;
	private String downprice;
	
	private Vector<String> ItemsToPurchase = new Vector<String>();
	public static Vector<Object> OrderDeatails = new Vector<Object>();
	
	public int calc=0;
	
	 */
	
	
	
	
	
	public MainSystemManger() {
		super();
		initialize();
	}

	/**
	 * 
	 */
	private void initialize() {
		this.setSize(1000, 720);
		this.setContentPane(MainSystemMangerForm());
		this.setTitle("MAIN SCREEN");	
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				Client client2 = new Client(host,DEFAULT_PORT);
				client2.accept(gui.MainPanel.Userinfo);										
				System.exit(0);	
			}
		});
		
		
	}
	private JPanel MainSystemMangerForm() {
		if (mainform == null) {
			ImageIcon imageBack = new ImageIcon("4.jpg");
			ImageIcon welcome = new ImageIcon("welcome1.gif");	
			jLabelBackground = new JLabel();
			jLabelBackground.setBounds(new Rectangle(2, 0, 981, 683));
			jLabelBackground.setIcon(imageBack);
			jLabelLogIn = new JLabel();
			jLabelLogIn.setBounds(new Rectangle(285, 616, 168, 35));
			jLabelLogIn.setText("YOUR LAST LOGIN WAS ON:");
			jLabelWelcome = new JLabel();
			jLabelWelcome.setBounds(new Rectangle(219, 18, 521, 146));
			jLabelWelcome.setIcon(welcome);
			mainform = new JPanel();
			mainform.setLayout(null);
			mainform.setBackground(Color.CYAN); 
			mainform.add(jLabelWelcome, null);
		
			mainform.add(getJButtonOrder(), null);
			mainform.add(getJButtonExit(), null);
			mainform.add(getJButtonHelp(), null);
			mainform.add(jLabelLogIn, null);
			mainform.add(getJTextFieldloginInfo(), null);
			mainform.add(jLabelBackground, null);
			 


		}
		return mainform; 
	}

	/**
	 * This method initializes jButtonCatalog	
	 * 	
	 * @return javax.swing.JButton	
	 */
	

	/**
	 * This method initializes jButtonOrder	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonOrder() {
		if (jButtonOrder == null) {
			jButtonOrder = new JButton();
			jButtonOrder.setBounds(new Rectangle(315, 316, 318, 74));
			jButtonOrder.setText("BLOCK CLIENT PERMISSION");
			jButtonOrder.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					BlockCommit NewBlockComm = new BlockCommit();
					NewBlockComm.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					NewBlockComm.setSize( 1000,720 ); // set frame size
					NewBlockComm.setResizable(true);
					NewBlockComm.setVisible( true ); // display frame
					MainSystemManger.this.dispose();
				}
			});
		}
		return jButtonOrder;
	}

	/**
	 * This method initializes jButtonExit	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonExit() {
		if (jButtonExit == null) {
			jButtonExit = new JButton();
			jButtonExit.setBounds(new Rectangle(825, 616, 91, 47));
			jButtonExit.setText("EXIT");
			jButtonExit.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					ExitFrame EFrame = new ExitFrame();
				    EFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
				    EFrame.setSize( 300,200 ); // set frame size
				    EFrame.setResizable(true);
				    EFrame.setVisible( true ); // display frame
		
				    
				    
				}
			});
		}
		return jButtonExit;
	}

	/**
	 * This method initializes jButtonHelp	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonHelp() {
		if (jButtonHelp == null) {
			jButtonHelp = new JButton();
			jButtonHelp.setBounds(new Rectangle(61, 616, 90, 45));
			jButtonHelp.setText("HELP");
			jButtonHelp.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					HelpFrame HFrame = new HelpFrame();

					HFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					HFrame.setSize( 600,720 ); // set frame size
					HFrame.setResizable(false);
					HFrame.setVisible( true ); // display frame
				}
			});
		}
		return jButtonHelp;
	}

	/**
	 * This method initializes jTextFieldloginInfo	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldloginInfo() {
		if (jTextFieldloginInfo == null) {
			jTextFieldloginInfo = new JTextField();
			jTextFieldloginInfo.setBounds(new Rectangle(465, 616, 137, 35));
		}
		return jTextFieldloginInfo;
	}
	
}  //  @jve:decl-index=0:visual-constraint="26,28"
